<script>
    $(function () {
        layui.use(['form', 'table'], function () {
            var form = layui.form,
                layer = layui.layer,
                table = layui.table,
                $ = layui.$;

            /**
             * 初始化表单，要加上，不然刷新部分组件可能会不加载
             */
            form.render();


            //监听select
            form.on('select(dep2)', function (data) {
                var url = "/showPost?dep=" + data.value;
                $.get(url, function (data) {
                    var tmp = '<option value="">请选择</option>';
                    for (var i in data) {
                        /*alert(data[i]);*/
                        tmp += '<option value="' + data[i] + '">' + data[i] + '</option>';
                    }
                    $("#rsbMonPost2").html(tmp);
                    //重载select模块，否则不会展示
                    layui.form.render("select");
                });
            })

            // 当前弹出层，防止ID被覆盖
            var parentIndex = layer.index;

            //监听提交
            /*form.on('submit(saveBtn)', function (data) {
                var index = layer.alert(JSON.stringify(data.field), {
                    title: '最终的提交信息'
                }, function () {
                    // 关闭弹出层
                    layer.close(index);
                    layer.close(parentIndex);

                });
                return false;
            });*/
            //监听提交
            form.on('submit(saveBtn)', function (data) {
                var datas=data.field;
                $.ajax({
                    url:"/rsb/money",
                    method:'get',
                    data: datas,
                    dataType:"json",
                    success:function(data){
                        console.log(data);
                    }
                })
            });

        });

    })

</script>
<div class="layuimini-main">
    <div class="layui-form layuimini-form">
        <form class="layui-form" action="">
            <div class="layui-form-item">
                <label class="layui-form-label required">编号</label>
                <div class="layui-input-block">
                    <input  name="rsbMonNum" id="rsbMonNum" lay-verify="required" lay-reqtext="编号不能为空" placeholder="请输入工资项编号"
                            class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">部门</label>
                <div class="layui-input-inline">
                    <select name="rsbMonDep" id="rsbMonDep" lay-verify="required" lay-reqtext="部门不能为空" lay-filter="dep2">
                        <option></option>
                        <option value="人事部">人事部</option>
                        <option value="销售部">销售部</option>
                        <option value="生产部">生产部</option>
                        <option value="财务部">财务部</option>
                        <option value="研发部">研发部</option>
                        <option value="物资部">物资部</option>
                        <option value="无">无</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">职位</label>
                <div class="layui-input-inline">
                    <select name="rsbMonPost" id="rsbMonPost2" lay-verify="required" lay-reqtext="职位不能为空">
                    <option>请先选择部门</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">基本工资</label>
                <div class="layui-input-block">
                    <input type="number" id="rsbMonBasepay" name="rsbMonBasepay" lay-verify="required" lay-reqtext="基本工资不能为空" placeholder="请输入基本工资"
                             class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">加班费/h</label>
                <div class="layui-input-block">
                    <input type="number" id="rsbMonAdd" name="rsbMonAdd"  placeholder="请输入每小时加班费" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">餐补/月</label>
                <div class="layui-input-block">
                    <input type="number" id="rsbMonEat" name="rsbMonEat"  placeholder="请输入每月餐补"
                             class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">交通补贴/月</label>
                <div class="layui-input-block">
                    <input type="number" id="rsbMonTraffic" name="rsbMonTraffic"  placeholder="请输入每月交通补贴" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">迟到早退/次（罚）</label>
                <div class="layui-input-block">
                    <input type="number" name="rsbMonLate" id="rsbMonLate" lay-verify="required" lay-reqtext="迟到早退罚款不能为空" placeholder="请输入每次迟到早退罚款"
                             class="layui-input">
                </div>
            </div><div class="layui-form-item">
                <label class="layui-form-label required">缺勤/天（罚）</label>
                <div class="layui-input-block">
                    <input type="number" name="rsbMonNocome" id="rsbMonNocome" lay-verify="required" lay-reqtext="缺勤罚款不能为空" placeholder="请输入缺勤罚款"
                             class="layui-input">
                </div>
            </div><div class="layui-form-item">
                <label class="layui-form-label">通讯补贴/月</label>
                <div class="layui-input-block">
                    <input type="number" name="rsbMonPhone" id="rsbMonPhone" placeholder="请输入每月通讯补贴" class="layui-input">
                </div>
            </div><div class="layui-form-item">
                <label class="layui-form-label required">五险一金/月</label>
                <div class="layui-input-block">
                    <input type="number" name="rsbMonFive" id="rsbMonFive" lay-verify="required" lay-reqtext="五险一金不能为空" placeholder="请输入五险一金"
                             class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">备注信息</label>
                <div class="layui-input-block">
                    <textarea name="remark" class="layui-textarea" placeholder="请输入备注信息"></textarea>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
                </div>
            </div>
        </form>
    </div>
</div>